package com.view
{
	import com.greensock.TweenLite;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.geom.Point;

	public class MapSprite extends Sprite
	{
		private var map:Bitmap;
		private var mapData:BitmapData;
		private var miniView:MiniMap;
		
		public function MapSprite()
		{
			map = new Bitmap();
			miniView = new MiniMap();
			addChild(map);
			addChild(miniView);
			miniView.x = 640;
			miniView.y = 5;
		}
		public function get point():Point
		{
			return new Point(map.x,map.y);
		}
		
		public function set data(data:Object):void
		{
			mapData = data as BitmapData;
			map.bitmapData = mapData.clone();
			miniView.data = mapData;
		}
		public function setSite(newX:Number,newY:Number):void
		{
			map.x = newX;	
			map.y = newY;
		}
		public function setTweenSite(newX:Number,newY:Number,backFun:Function = null ):void
		{
			if(backFun == null)
				backFun = function():void{MyMap_2.ins.moveState = false;return ;};
			var times:Number = Math.sqrt((map.x - newX) * (map.x - newX) + (map.y - newY) * (map.y - newY)) / MyMap_2.ins.speed;
			TweenLite.to(map,times,{x:newX,y:newY,onComplete:backFun});
		}
		
	}
}